<template>
  <div>
    <Echert :option="option"></Echert>
  </div>
</template>

<script>
import Echert from '@/components/Echerts/GoodsEcherts.vue'
import { orderEcharts } from '@/api/orders.js'
import moment from 'moment'
export default {
  components: {
    Echert
  },
  data() {
    return {
      option: {}
    }
  },
  created() {
    this.getorder()
  },

  methods: {
    async getorder() {
      const { data } = await orderEcharts({
        date: '["2010-10-01 00:00:00", "2021-10-10 00:00:00"]'
      })
      data.forEach(item => {
        item.orderTime = moment(item.orderTime).format('YYYY-MM-DD')
      })
      const Xdata = {}
      data.forEach(item => {
        Xdata[item.orderTime] = (Xdata[item.orderTime] || 0) + item.orderAmount
      })
      this.option = Xdata
    }
  }
}
</script>

<style lang="less" scoped></style>
